<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <c:set var="root" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<script type="text/javascript">
var content="";
$(function (){
	$.post("${root}/indexservlet?state=initnav",function (data){
		//alert(data);
		$.each(data,function(){
			content+="<li><a href='${root}/indexservlet?state=categorypage&page=1&cid="+this.cid+"'>"+this.cname+"</a></li>"
		});
		$("#ulnav").html(content);
	},"json");
});
</script>

<script type="text/javascript">
		function search(){
			window.location = "${pageContext.request.contextPath }/Keysearch?state=search";
		}
		
</script>


<!-- 登录 注册 购物车... -->
<div class="container-fluid">
	<div class="col-md-4">
		<img src="img/logo.png" />
	</div>
	<div class="col-md-5">
		<img src="img/header.png" />
	</div>
	<div class="col-md-3" style="padding-top:20px">
		<ol class="list-inline">
			<!-- empty判断不为空的时候才输出 -->
			<c:if test="${empty user }">
					<li><a href="${root }/login.jsp">登录</a></li>
					<li><a href="register.jsp">注册</a></li>
			</c:if>
			<c:if test="${not empty user}">
				<li><a href="#">${user.username }</a></li>
				<li><a href ="${root }/loginOut.jsp">注销</a></li>
			</c:if>
			<c:if test="${not empty user}">
			<li><a href="${root }/cartServlet?state=direct">购物车</a></li>
			<li><a href="${root }/ProductServlet?state=myOrders">我的订单</a></li>
			</c:if>
		</ol>
	</div>
</div>

<!-- 导航条 -->
<div class="container-fluid">
	<nav class="navbar navbar-inverse">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="${root }/">首页</a>
			</div>

			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav" id="ulnav">
				<!--  	<li class="active"><a href="product_list.htm">手机数码<span class="sr-only">(current)</span></a></li>
					<li><a href="#">电脑办公</a></li>
					<li><a href="#">电脑办公</a></li>
					<li><a href="#">电脑办公</a></li>-->
					<!--<c:forEach items ="${categoryList}" var ="category">
					<li><a href="#" >${category.cname}</a></li>
					</c:forEach>-->
				</ul>
				<form action="${root }/Keysearch?state=search"  method = "post"class="navbar-form navbar-right" role="search">
					<div class="form-group">
						<input type="text" class="form-control" placeholder="Search" name = "search">
					</div>
					<button type="submit" class="btn btn-default" >Submit</button>
					
				</form>
			</div>
		</div>
	</nav>
</div>